package com.bojx.report.service;

import java.util.ArrayList;
import java.util.List;

import com.bojx.report.dao.StatisticDao;
import com.bojx.report.pojo.StatisticResult;

public class StatisticService {
	private static StatisticDao stDao=new StatisticDao();
	
	public List<StatisticResult> count(Integer year,Integer month){
		List<StatisticResult> data=new ArrayList<>();
		//已经上传的数量
		Integer uploadedNum=stDao.countUploadedNum(year, month);
		//全部数量
		Integer totalNum=stDao.countTotalNum();
		StatisticResult uploadedRecord=new StatisticResult();
		uploadedRecord.setName("已经上传");
        uploadedRecord.setValue(uploadedNum);
        data.add(uploadedRecord);
        StatisticResult unuploadedRecord=new StatisticResult();
        unuploadedRecord.setName("暂未上传");
        unuploadedRecord.setValue(totalNum-uploadedNum);
        data.add(unuploadedRecord);
		return data;
	}

	public List<String> findBankUnupload(Integer year, Integer month) {
		//全部银行
		List<String> totalBank=stDao.queryAllBanks();
		List<String> uploadedBank=stDao.queryUploadedBanks(year,month);
		totalBank.removeAll(uploadedBank);//留下剩余的没有上传的
		return totalBank;
	}

	public List<StatisticResult> countByQuarter(Integer year,Integer quarter){
		List<StatisticResult> data=new ArrayList<>();
		//已经上传的数量
		Integer uploadedNum=stDao.countUploadedNumByQuarter(year, quarter);
		//全部数量
		Integer totalNum=stDao.countTotalNum();
		StatisticResult uploadedRecord=new StatisticResult();
		uploadedRecord.setName("已经上传");
        uploadedRecord.setValue(uploadedNum);
        data.add(uploadedRecord);
        StatisticResult unuploadedRecord=new StatisticResult();
        unuploadedRecord.setName("暂未上传");
        unuploadedRecord.setValue(totalNum-uploadedNum);
        data.add(unuploadedRecord);
		return data;
	}

	public List<String> findBankUnuploadByQuarter(Integer year, Integer quarter) {
		//全部银行
		List<String> totalBank=stDao.queryAllBanks();
		List<String> uploadedBank=stDao.queryUploadedBanksByQuarter(year,quarter);
		totalBank.removeAll(uploadedBank);//留下剩余的没有上传的
		return totalBank;
	}
}
